<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body>
  <button class="layui-btn layui-btn-danger">按钮</button>

  <div id="rate"></div>
  <script src="./layui/layui.js"></script>
  <script>
    layui.use(['jquery', 'rate'], function(){
      // layui
      var $ = layui.jquery;
      var rate = layui.rate;

      // $(function(){
      //   alert(1)
      // })
      // 评分组件
      var rateIns = rate.render({
        elem: '#rate',
        length: 10,
        value: 10,
        theme: "#f99",
        text: true,
        choose: function(value){
          if (value === 10) {
            alert('感谢您的10分好评')
          }
          if(value < 3) {
            alert('渣男，终究是错付了')
          }
        }
      })
    });
  </script>
</body>
</html>